Repeated Permutation

#include <iostream>
#include <vector>
using namespace std;
void repeatPermutation(vector<int> vec, vector<int> perm, vector<vector<int>>& ret, int depth){
if (depth==perm.size()){
ret.push_back(perm);
return;
}
for(int i=0; i<vec.size(); ++i){
perm[depth]=vec[i];
repeatPermutation(vec, perm, ret, depth+1);
}
}
int main(void){
const int r=3;
vector<int> vec={1, 2, 3};
vector<int> perm(r);
vector<vector<int>> ret;
repeatPermutation(vec, perm, ret, 0);
for(vector<int> vv: ret){
for(int ii: vv) cout<<ii<<" ";
cout<<endl;
}
return 0;
}